window: Add support for enabling client decorations on non-Wayland
authorMatthias Clasen <mclasen@redhat.com>
Sun, 17 Mar 2013 16:06:26 +0000 (12:06 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 17 Mar 2013 16:19:49 +0000 (12:19 -0400)
Client side decorations can be enabled on non-Wayland platforms by
setting the GTK_CSD="1" environment variable.

We must ensure we have a GdkVisual that has an alpha channel since
the decorations rely on transparency. If we cannot get a visual with
an alpha channel then we do not enable client side decorations.

gtk/gtkwindow.c

index 45d8a36d92c6484d215dc65dde6e6a6218014a10..bd09f8b286f7d9b924f0b861654505eb1d756ed9 100644 (file)
@@ -4855,16 +4855,26 @@ create_decoration (GtkWidget *widget)
     return;
 
 #ifdef GDK_WINDOWING_WAYLAND
-  if (!GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)))
-    return;
-#else
-  return;
+  if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)))
+    priv->client_decorated = TRUE;
 #endif
 
-  if (!priv->decorated)
-    return;
+  if (!priv->client_decorated &&
+      g_strcmp0 (g_getenv ("GTK_CSD"),"1") == 0)
+    {
+      GdkVisual *visual;
+
+      /* We need a visual with alpha */
+      visual = gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget));
+      if (visual)
+        {
+          gtk_widget_set_visual (widget, visual);
+          priv->client_decorated = TRUE;
+        }
+    }
 
-  priv->client_decorated = TRUE;
+  if (!priv->client_decorated)
+    return;
 
   priv->title_box = gtk_header_bar_new ();
   g_object_set (priv->title_box,